clc 
close all
clear all
sample_size = 2000;
coefficient = 8/6;
COMPUTE_STD = 0;
COMPUTE_COV = 1;
if (COMPUTE_STD == 1)
  %%PRKS
  prks95_delayslot = GetLinkStd('prks95_delayslot_type2.txt',sample_size);
  prks95_delayslot = sort(prks95_delayslot);
  prks90_delayslot = GetLinkStd('prks90_delayslot_type2.txt',sample_size);
  prks90_delayslot = sort(prks90_delayslot);
  prks80_delayslot = GetLinkStd('prks80_delayslot_type2.txt',sample_size);
  prks80_delayslot = sort(prks80_delayslot);
  prks70_delayslot = GetLinkStd('prks70_delayslot_type2.txt',sample_size);
  prks70_delayslot = sort(prks70_delayslot);
  prks60_delayslot = GetLinkStd('prks60_delayslot_type2.txt',sample_size);
  prks60_delayslot = sort(prks60_delayslot);
  prks50_delayslot = GetLinkStd('prks50_delayslot_type2.txt',sample_size);
  prks50_delayslot = sort(prks50_delayslot);
  prks40_delayslot = GetLinkStd('prks40_delayslot_type2.txt',sample_size);
  prks40_delayslot = sort(prks40_delayslot);
  prks30_delayslot = GetLinkStd('prks40_delayslot_type2.txt',sample_size);
  prks30_delayslot = sort(prks30_delayslot);
  %%RID
  rid95_delayslot = GetLinkStd('rid95_delayslot_type2.txt',sample_size);
  rid95_delayslot = sort(rid95_delayslot);
  rid90_delayslot = GetLinkStd('rid90_delayslot_type2.txt',sample_size);
  rid90_delayslot = sort(rid90_delayslot);
  rid80_delayslot = GetLinkStd('rid80_delayslot_type2.txt',sample_size);
  rid80_delayslot = sort(rid80_delayslot);
  rid70_delayslot = GetLinkStd('rid70_delayslot_type2.txt',sample_size);
  rid70_delayslot = sort(rid70_delayslot);
  %%B-MAC
  csma_delayslot = GetLinkStd('csma_delayslot_type2.txt',sample_size);
  csma_delayslot = sort(csma_delayslot*8/6);
  %%S-MAC
  rtscts_delayslot = GetLinkStd('rtscts_delayslot_type2.txt',sample_size);
  rtscts_delayslot = sort(rtscts_delayslot*8/6);
  %%CMAC
  cmac95_delayslot = GetLinkStd('cmac95_delayslot_type2.txt',sample_size);
  cmac95_delayslot = sort(cmac95_delayslot*8/6);
  cmac90_delayslot = GetLinkStd('cmac90_delayslot_type2.txt',sample_size);
  cmac90_delayslot = sort(cmac90_delayslot*8/6);
  cmac80_delayslot = GetLinkStd('cmac80_delayslot_type2.txt',sample_size);
  cmac80_delayslot = sort(cmac80_delayslot*8/6);
  cmac70_delayslot = GetLinkStd('cmac70_delayslot_type2.txt',sample_size);
  cmac70_delayslot = sort(cmac70_delayslot*8/6);
  %%SCREAM
  scream_delayslot = GetLinkStd('scream_delayslot_type2.txt',sample_size);
  scream_delayslot = sort(scream_delayslot);
  %%---------------------CDF PLOT--------------------------------------------
  h1 = cdfplot(prks95_delayslot);
  hold on;
  set(h1, 'color', 'r', 'Marker', '*');
  h2 = cdfplot(prks90_delayslot);
  hold on;
  set(h2, 'color', 'r', 'Marker', '+');
  h3 = cdfplot(prks80_delayslot);
  hold on;
  set(h3, 'color', 'r', 'Marker', 'o');
  h4 = cdfplot(prks70_delayslot);
  hold on;
  set(h4, 'color', 'r', 'Marker', 'x');
  h_prks60 = cdfplot(prks60_delayslot);
  hold on;
  set(h_prks60, 'color', 'r', 'Marker', '.');
  h_prks50 = cdfplot(prks50_delayslot);
  hold on;
  set(h_prks50, 'color', 'r', 'Marker', 's');
  h_prks40 = cdfplot(prks40_delayslot);
  hold on;
  set(h_prks40, 'color', 'r', 'Marker', 'd');
  h_prks30 = cdfplot(prks30_delayslot);
  hold on;
  set(h_prks30, 'color', 'r', 'Marker', '^');


  h5 = cdfplot(rid95_delayslot);
  hold on;
  set(h5, 'color', 'c', 'Marker','*');
  h6 = cdfplot(rid90_delayslot);
  hold on;
  set(h6, 'color', 'c', 'Marker', '+');
  h7 = cdfplot(rid80_delayslot);
  hold on;
  set(h7, 'color', 'c', 'Marker', 'o');
  h8 = cdfplot(rid70_delayslot);
  hold on;
  set(h8, 'color', 'c', 'Marker', 'x');

  h9 = cdfplot(cmac95_delayslot);
  hold on;
  set(h9, 'color', 'b', 'Marker', '*');
  h10 = cdfplot(cmac90_delayslot);
  hold on;
  set(h10, 'color', 'b', 'Marker', '+');
  h11 = cdfplot(cmac80_delayslot);
  hold on;
  set(h11, 'color', 'b', 'Marker', 'o');
  h12 = cdfplot(cmac70_delayslot);
  hold on;
  set(h12, 'color', 'b', 'Marker', 'x');

  h13 = cdfplot(csma_delayslot);
  hold on;
  set(h13, 'color', 'm');

  h14 = cdfplot(rtscts_delayslot);
  hold on;
  set(h14, 'color', 'k');

  h15 = cdfplot(scream_delayslot);
  hold on;
  set(h15, 'color', 'g');
  legend ('PRKS95','PRKS90','PRKS80','PRKS70','PRKS60','PRKS50','PRKS40','PRKS30','RIDB95','RIDB90','RIDB80','RIDB70','CMAC95','CMAC90','CMAC80','CMAC70','CSMA','RTS-CTS','SCREAM');
  set(gca,'XScale','log');
  xlabel('Log(std delay)');
end

if (COMPUTE_COV == 1)
  %%PRKS
  prks95_delayslot = GetLinkCov('prks95_delayslot_type2.txt',sample_size);
  prks95_delayslot = sort(prks95_delayslot);
  prks90_delayslot = GetLinkCov('prks90_delayslot_type2.txt',sample_size);
  prks90_delayslot = sort(prks90_delayslot);
  prks80_delayslot = GetLinkCov('prks80_delayslot_type2.txt',sample_size);
  prks80_delayslot = sort(prks80_delayslot);
  prks70_delayslot = GetLinkCov('prks70_delayslot_type2.txt',sample_size);
  prks70_delayslot = sort(prks70_delayslot);
  prks60_delayslot = GetLinkCov('prks60_delayslot_type2.txt',sample_size);
  prks60_delayslot = sort(prks60_delayslot);
  prks50_delayslot = GetLinkCov('prks50_delayslot_type2.txt',sample_size);
  prks50_delayslot = sort(prks50_delayslot);
  prks40_delayslot = GetLinkCov('prks40_delayslot_type2.txt',sample_size);
  prks40_delayslot = sort(prks40_delayslot);
  prks30_delayslot = GetLinkCov('prks40_delayslot_type2.txt',sample_size);
  prks30_delayslot = sort(prks30_delayslot);
  %%RID
  rid95_delayslot = GetLinkCov('rid95_delayslot_type2.txt',sample_size);
  rid95_delayslot = sort(rid95_delayslot);
  rid90_delayslot = GetLinkCov('rid90_delayslot_type2.txt',sample_size);
  rid90_delayslot = sort(rid90_delayslot);
  rid80_delayslot = GetLinkCov('rid80_delayslot_type2.txt',sample_size);
  rid80_delayslot = sort(rid80_delayslot);
  rid70_delayslot = GetLinkCov('rid70_delayslot_type2.txt',sample_size);
  rid70_delayslot = sort(rid70_delayslot);
  %%B-MAC
  csma_delayslot = GetLinkCov('csma_delayslot_type2.txt',sample_size);
  csma_delayslot = sort(csma_delayslot*8/6);
  %%S-MAC
  rtscts_delayslot = GetLinkCov('rtscts_delayslot_type2.txt',sample_size);
  rtscts_delayslot = sort(rtscts_delayslot*8/6);
  %%CMAC
  cmac95_delayslot = GetLinkCov('cmac95_delayslot_type2.txt',sample_size);
  cmac95_delayslot = sort(cmac95_delayslot*8/6);
  cmac90_delayslot = GetLinkCov('cmac90_delayslot_type2.txt',sample_size);
  cmac90_delayslot = sort(cmac90_delayslot*8/6);
  cmac80_delayslot = GetLinkCov('cmac80_delayslot_type2.txt',sample_size);
  cmac80_delayslot = sort(cmac80_delayslot*8/6);
  cmac70_delayslot = GetLinkCov('cmac70_delayslot_type2.txt',sample_size);
  cmac70_delayslot = sort(cmac70_delayslot*8/6);
  %%SCREAM
  scream_delayslot = GetLinkCov('scream_delayslot_type2.txt',sample_size);
  scream_delayslot = sort(scream_delayslot);
  %%---------------------CDF PLOT--------------------------------------------
  h1 = cdfplot(prks95_delayslot);
  hold on;
  set(h1, 'color', 'r', 'Marker', '*');
  h2 = cdfplot(prks90_delayslot);
  hold on;
  set(h2, 'color', 'r', 'Marker', '+');
  h3 = cdfplot(prks80_delayslot);
  hold on;
  set(h3, 'color', 'r', 'Marker', 'o');
  h4 = cdfplot(prks70_delayslot);
  hold on;
  set(h4, 'color', 'r', 'Marker', 'x');
  h_prks60 = cdfplot(prks60_delayslot);
  hold on;
  set(h_prks60, 'color', 'r', 'Marker', '.');
  h_prks50 = cdfplot(prks50_delayslot);
  hold on;
  set(h_prks50, 'color', 'r', 'Marker', 's');
  h_prks40 = cdfplot(prks40_delayslot);
  hold on;
  set(h_prks40, 'color', 'r', 'Marker', 'd');
  h_prks30 = cdfplot(prks30_delayslot);
  hold on;
  set(h_prks30, 'color', 'r', 'Marker', '^');


  h5 = cdfplot(rid95_delayslot);
  hold on;
  set(h5, 'color', 'c', 'Marker','*');
  h6 = cdfplot(rid90_delayslot);
  hold on;
  set(h6, 'color', 'c', 'Marker', '+');
  h7 = cdfplot(rid80_delayslot);
  hold on;
  set(h7, 'color', 'c', 'Marker', 'o');
  h8 = cdfplot(rid70_delayslot);
  hold on;
  set(h8, 'color', 'c', 'Marker', 'x');

  h9 = cdfplot(cmac95_delayslot);
  hold on;
  set(h9, 'color', 'b', 'Marker', '*');
  h10 = cdfplot(cmac90_delayslot);
  hold on;
  set(h10, 'color', 'b', 'Marker', '+');
  h11 = cdfplot(cmac80_delayslot);
  hold on;
  set(h11, 'color', 'b', 'Marker', 'o');
  h12 = cdfplot(cmac70_delayslot);
  hold on;
  set(h12, 'color', 'b', 'Marker', 'x');

  h13 = cdfplot(csma_delayslot);
  hold on;
  set(h13, 'color', 'm');

  h14 = cdfplot(rtscts_delayslot);
  hold on;
  set(h14, 'color', 'k');

  h15 = cdfplot(scream_delayslot);
  hold on;
  set(h15, 'color', 'g');
  legend ('PRKS95','PRKS90','PRKS80','PRKS70','PRKS60','PRKS50','PRKS40','PRKS30','RIDB95','RIDB90','RIDB80','RIDB70','CMAC95','CMAC90','CMAC80','CMAC70','CSMA','RTS-CTS','SCREAM');
  set(gca,'XScale','log');
  xlabel('Log(cov delay)');
end
